package com.jsb.laundry.service.impl;

import com.jsb.laundry.dao.UserLotteryDao;
import com.jsb.laundry.model.entity.CapitalAccount;
import com.jsb.laundry.model.entity.CapitalAccountLog;
import com.jsb.laundry.model.vo.*;
import com.jsb.laundry.service.UserLotteryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserLotteryServiceImpl implements UserLotteryService {
    @Resource
    private UserLotteryDao userLotteryDao;

    /**
     * 抽奖列表
     *
     * @return
     */
    @Override
    public List<UserLotteryPrizeListVo> list() {
        return userLotteryDao.list();
    }

    /**
     * 用户信息
     *
     * @param userId
     * @return
     */
    @Override
    public UserLotteryListVO findByUserLotteryNum(String userId) {
        return userLotteryDao.findByUserLotteryNum(userId);
    }

    /**
     * 减去抽奖次数
     *
     * @param num
     * @param userId
     * @return
     */
    @Override
    public int updateNumberSub(int num, String userId) {
        return userLotteryDao.updateNumberSub(num,userId);
    }

    /**
     * 加上
     *
     * @param num
     * @param userId
     * @return
     */
    @Override
    public int updateNumberAdd(int num, String userId) {
        return userLotteryDao.updateNumberAdd(num,userId);
    }

    /**
     * 添加抽奖记录
     *
     * @param prizeId
     * @param userId
     * @return
     */
    @Override
    public int addLotteryRecords(String prizeId, String userId,String orderId) {
        return userLotteryDao.addLotteryRecords(prizeId,userId,orderId);
    }

    /**
     * 减去奖品表数量
     *
     * @param prizeNum
     * @param id
     * @return
     */
    @Override
    public int updatePrizeNumSub(int prizeNum, String id) {
        return userLotteryDao.updatePrizeNumSub(prizeNum,id);
    }

    /**
     * 新增已结算日志
     *
     * @param capitalAccountLog
     * @return
     */
    @Override
    public int capitalAccountLogadd(CapitalAccountLog capitalAccountLog) {
        return userLotteryDao.capitalAccountLogadd(capitalAccountLog);
    }

    /**
     * 查询改奖品多少钱
     *
     * @param id
     * @return
     */
    @Override
    public int findByPrizeMoney(String id) {
        return userLotteryDao.findByPrizeMoney(id);
    }

    /**
     * 查询资金账户基本信息
     *
     * @param thirdpartId
     * @param type
     * @return
     */
    @Override
    public CapitalAccount capitalAccountInfo(String thirdpartId, String type) {
        return userLotteryDao.capitalAccountInfo(thirdpartId,type);
    }

    /**
     * 更新已结算
     *
     * @param amount
     * @param id
     * @return
     */
    @Override
    public int updateDepositSub(int amount, String id) {
        return userLotteryDao.updateDepositSub(amount,id);
    }

    @Override
    public int updateDepositAdd(int amount, String id) {
        return userLotteryDao.updateDepositAdd(amount,id);
    }

    /**
     * 抽奖邀请人人加次数
     *
     * @param userId
     * @param num
     * @return
     */
    @Override
    public int updUserLotteryNum(String userId, int num) {
        return userLotteryDao.updUserLotteryNum(userId,num);
    }

    /**
     * 抽奖邀请人邀请被邀请人
     *
     * @param userId
     * @param invitee
     * @return
     */
    @Override
    public int addUserLotteryInvitation(String userId, String invitee) {
        return userLotteryDao.addUserLotteryInvitation(userId,invitee);
    }

    /**
     * 抽奖邀请途径加次数
     *
     * @param userId
     * @param access
     * @param obtainedTimes
     * @return
     */
    @Override
    public int addUserLotteryRecordRoad(String userId, String access, String accessType, int obtainedTimes) {
        return userLotteryDao.addUserLotteryRecordRoad(userId,access,accessType,obtainedTimes);
    }

    /**
     * 注册后添加到抽奖表
     *
     * @param userId
     * @return
     */
    @Override
    public int addUserLotteryInfo(String userId) {
        return userLotteryDao.addUserLotteryInfo(userId);
    }

    /**
     * 抽奖中奖列表
     *
     * @return
     */
    @Override
    public List<UserLuckDrawAwardListVo> userLuckyDrawAwardList() {
        return userLotteryDao.userLuckyDrawAwardList();
    }

    /**
     * 邀请人计数
     *
     * @param userId
     * @return
     */
    @Override
    public UserLuckyDrawAwardCountVo userLuckyDrawAwardCount(String userId) {
        return userLotteryDao.userLuckyDrawAwardCount(userId);
    }

    /**
     * 分享朋友圈列表次数查询
     *
     * @param userId
     * @param startTime
     * @param endTime
     * @return
     */
    @Override
    public int findByLotteryUserCount(String userId, String startTime, String endTime) {
        return userLotteryDao.findByLotteryUserCount(userId,startTime,endTime);
    }

    /**
     * 添加分享朋友圈次数
     *
     * @param userId
     * @param num
     * @return
     */
    @Override
    public int addLotteryUser(String userId, int num) {
        return userLotteryDao.addLotteryUser(userId,num);
    }

    /**
     * 查询用户抽奖次数
     *
     * @param userId
     * @return
     */
    @Override
    public int numBerLotteryDraws(String userId) {
        return userLotteryDao.numBerLotteryDraws(userId);
    }

    /**
     * 已结算
     *
     * @param userId
     * @return
     */
    @Override
    public List<CapitalAccountUnstLogListVo> capitalAccountLogList(String userId) {
        return userLotteryDao.capitalAccountLogList(userId);
    }

    /**
     * 根据骑手id查询骑手手机号
     *
     * @param userId
     * @return
     */
    @Override
    public String findByPhone(String userId) {
        return userLotteryDao.findByPhone(userId);
    }

    /**
     * 查询c端是否存在该手机号
     *
     * @param userPhone
     * @return
     */
    @Override
    public int findByUserPhone(String userPhone) {
        return userLotteryDao.findByUserPhone(userPhone);
    }

    /**
     * 根据手机号查询userId
     *
     * @param userPhone
     * @return
     */
    @Override
    public String findByUserId(String userPhone) {
        return userLotteryDao.findByUserId(userPhone);
    }

    /**
     * 活动规则
     *
     * @return
     */
    @Override
    public List<FindByRuleVo> findByRule() {
        return userLotteryDao.findByRule();
    }
}
